<?php

if (isset($_POST["name"])) {
    echo $_POST["name"];
} else {
    echo 'NOTHING';
}

?>

<?php
$servername = "mysql";
$username = "root";
$password = "password";
$dbname = "test";

// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}
if (isset($_POST["name"])) {
    $sql = "insert into product(name) values('".$_POST["name"]."')";
} else {
    echo 'NOTHING';
}

if ($conn->query($sql) === TRUE) {
    echo "新记录插入成功";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
<ul>
    <li><a href="add_form.html">add_form.html</a></li>
    <li><a href="product.php">product</a></li>
</ul>




